package com.ssslogin.controller;

import com.ssslogin.pojo.Resume;
import com.ssslogin.service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA by ChouFy on 2020-03-11.
 *
 * @author zhoufy
 */
@Controller
@RequestMapping("/resume")
public class ResumeController {


    @Autowired
    private ResumeService resumeService;

    @RequestMapping("/list")
    public String list(Map<String, Object> map) {
        List<Resume> query = resumeService.query();
        map.put("list", query);
        return "list";
    }


    @RequestMapping("/addPage")
    public String addPage() {
        return "add";
    }


    @RequestMapping("/add")
    public String add(Resume resume) {
        resumeService.save(resume);
        return "redirect:/resume/list";
    }



    @RequestMapping("/form")
    public String form(Long id, Map<String, Object> map){
        Resume resume = resumeService.getByID(id);
        map.put("resume", resume);
        return "add";
    }


    @RequestMapping("/delete")
    public String delete(Resume resume) {
        resumeService.delete(resume);
        return "redirect:/resume/list";
    }
}
